# Create your views here.
from django.contrib.auth.forms import UserCreationForm
from django.db.models import Q
from django import forms as forms
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
#from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.forms import ModelForm

def register(request):
	
	user = request.user
	
	if request.method == 'POST':
		form1 = UserCreationForm(request.POST)
		email = request.POST['email']
		if form1.is_valid():
			data = request.POST.copy()
			new_user = form1.save(data)
			new_user.is_active = True
			new_user.email = email
			new_user.save()
			return HttpResponseRedirect("/search/")
	else:
		form1 = UserCreationForm()

	return render_to_response("registration/registration.html", {
		'form1' : form1,
		'user':user,
    })